In recent years, as a digital video signal compressing and encoding system, so-called MPEG (Moving Picture Experts Group) encoding system has been widely used. MPEG2 system is a standard dealing with a compression for a moving picture using DCT (Discrete Cosine Transform) and prediction encoding. In the MPEG2 system, video data for one frame is divided into macro blocks having a predetermined size each. Each macro block is predictively encoded using a moving vector. Each of the resultant macro blocks is divided into DCT blocks. Each of the DCT blocks is processed by the DCT. As a result, video data is encoded with a variable length code. At present time, the MPEG2 system that features higher expandability and higher picture quality than conventional MPEG system has been mainly used.
MPEG2 data is composed of a hierarchical data stream. As hierarchical layers, there are a sequence layer (highest layer), a GOP (Group Of Picture) layer, a picture layer, a slice layer, and a macro block layer (lowest layer) that are successively disposed. Each of these layers contains at least one lower layer structure. Each layer has a header portion. Each layer except for the macro block layer has a start code followed by a header portion.
A macro block is a block composed of 16 pixels×16 pixels. One slice is composed of at least one macro block. On the other hand, one picture corresponds to one screen. One slice cannot overlap between two adjacent pictures. In addition, a slice header is always placed on the left end of a screen. A slice start code contains vertical position information of the local slice. A lice header contains extended slice vertical position information, quantizing scale information, and so forth.
On the other hand, as was described above, an MPEG2 data stream has been encoded with a variable length code (VLC). In the variable length code encoding process, a code length corresponding to the occurrence frequency of data is assigned using a VLC table. When an MPEG2 data stream is decoded, the VLC is decoded with reference to the VLC table.
In recent years, a system that transmits a digital video signal between units and a system that records a digital video signal as an MPEG stream to a record medium such as a magnetic tape have been used in a broadcasting station and so forth. In such systems, an MPEG elementary stream is transmitted through for example an SDTI (Serial Data Transport Interface). The receiving side extracts an MPEG elementary stream from the SDTI and performs a predetermined process for the extracted MPEG elementary stream.
As was described above, a data stream compressed and encoded corresponding to the MPEG2 system is encoded with an error correction code. The resultant stream is transmitted. The error correction code encoding process is performed by using for example a Reed Solomon code and a product code. When an error is corrected (namely, data that has been encoded with an error correction code is decoded), if there is an error that is beyond the power of the error correction code, an error flag that represents such an error is output. In this case, such an error is not corrected.
When such an error is not corrected, a VLC that is output from an error correcting circuit, which corrects an error, is an irregular VLC. In other words, there is a possibility of which the VLC may have a code that is not contained on the VLC table. When such a VLC is input to the VLC decoder, since it cannot deal with an unexpected code, it may hang up.
FIG. 59 shows an example of which when an error takes place in a VLC, it vary. FIG. 59A shows a normal stream. An MPEG stream is a stream having a data width of eight bits (one byte). In a data sequence 400, a slice start code (slice_start_code) of 32 bits (4 bytes) that represents the beginning of the slice layer is followed by a slice header parameter of five bits quantizer_scale_code, an extra_bit_slice of one bit, a macro block layer parameter of a variable length code of one bit macro_address_increment, and a macro block layer parameter of a variable length code of one bit macroblock_type.
In FIG. 59A, in a data sequence 401 of a DCT block in the slice layer designated by the slice_start_code in the data sequence 400, the VLC is a stream of lines that have meanings corresponding to a VLC table (for example, DCT Coefficients Table 1 prescribed in the MPEG standard). The stream is as follows:
. . .
0100
0000—0001—0010—0
0001—010
0010—0110—1
100
. . .
In such a stream, it is assumed that a bit inversion takes place at a hatched position shown in FIG. 59A and an error flag is output at a position shown in FIG. 59B. Thus, the stream varies as shown in FIG. 59C. When the stream is applied to the forgoing VLC table, the stream becomes as follows.
. . .
0100
000013 0101—0010—0000—1010—0010
0110
1100
. . .
In the varied stream, corresponding to the forgoing VLC table (DCT Coefficients Table 1), the second line represents escape (0000—01) +run 18 (01—0010) +level 162 (0000—1010—0010). The third line represents EOB (End Of Block). Thus, if only one bit inversion takes place, there is a possibility of which a VLC may be decoded as a different VLC. Thus, a VLC after an error is not reliable even if the VLC is decoded. Thus, data until the next start code 402 should be discarded. As shown in FIG. 59, since the start code is a 32-bit unique code that is byte assigned, it can be detected. Thus, with the start code, the VLC decoder can be restored from an error.
In this case, data after an error that is beyond the power of an error correction code may be simply discarded with an error flag. However, there is a possibility of which data adjacent to the discarded portion may be changed to a VLC that has a code contained in the VLC table. As a result, the VLC decoder may hang up.
In addition, when a DC value of a DCT coefficient is lost due to an error, the MPEG2 decoder may interpret the lost DC value as “0”. In this case, the lost portion may be decoded as a green image. As a result, an abnormal image is displayed.
Thus, when video data is compressed and encoded with a VLC and then encoded with an error correction code, if an error takes place, it is difficult to accomplish a system that stably operates.
On the other hand, as was described above, an MPEG2 data stream is encoded with a VLC. The variable length code encoding process is performed by assigning a code length corresponding to the occurrence frequency of data using the VLC table. When a data stream is decoded, a VLC is decoded with reference to the VLC table. Thus, as was described with reference to FIG. 59, when an error takes place, until the next header (start code) is detected, a VLC cannot be relied.
Thus, in an MPEG decoder that decodes an MPEG stream, when a bit inversion takes place or when an invalid MPEG stream is input (for example, a stream breaks), because of a VLC that does not correspond to a syntax prescribed in the MPEG standard (namely, that is not contained on the VLC table that is referenced when the VLC is decoded), there is a possibility of which the MPEG decoder hangs up. Thus, it becomes difficult to accomplish a system that stably operates.
Therefore, an object of the present invention is to provide a stream processing apparatus that allows a system that stably operates to be accomplished even if a data stream that has been compressed and encoded with a VLC and that has been encoded with an error correction code has an error that is beyond the power of an error correction code.
Another object of the present invention is to provide a stream processing apparatus that stably operates even if an invalid VLC that is not contained in a VLC table that is referenced when the VLC is decoded is input to a system that handles an MPEG stream.